-
Notifications
You must be signed in to change notification settings - Fork 14.4k
[SYCL] Add libsycl, a SYCL RT library implementation project #144372
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
This patch introduces libsycl, a SYCL runtime library implementation, as a top-level LLVM runtime project. It contains the basic folder layout and CMake infrastructure to build a dummy SYCL library.
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Disclaimer: I haven't seen the RFCs related to this before and haven't read through them in detail.
I don't know much about SYCL, but I do know quite a bit about libc++ and why we do things in certain ways there. In case you're interested I'd be happy to talk to you about that. Feel free to contact me on Discord, Discourse or E-Mail if you'd like to set up a meeting.
libsycl/src/version.hpp.in
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src
seems like a weird place for a file that'll be part of the installed headers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I think that we use this approach to store file that is just an input for generator because of the way we copy headers. Probably a good chance to discuss this approach too.
I noticed that other projects do copy per file instead of doing copy of whole include
directory.
I think libcxx uses file list for headers to use copy_if_different tool that copies files only if they were changed. This approach allows to store input files in the same folder with full header files.
copy_directory_if_different is added in later version, in 3.26.
We use copy_directory that doesn't detect changes but works faster. At early stages I believe there is no noticeable difference.
Do you know if there is any other reason for other projects to copy headers per file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so, though I wasn't there for that specific part of libc++'s history. Maybe @ldionne knows more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
philnik777 thank you for the review, I really appreciate your comments and guidance.
I replied to all your comments and will provide code updates a bit later.
libsycl/src/version.hpp.in
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I think that we use this approach to store file that is just an input for generator because of the way we copy headers. Probably a good chance to discuss this approach too.
I noticed that other projects do copy per file instead of doing copy of whole include
directory.
I think libcxx uses file list for headers to use copy_if_different tool that copies files only if they were changed. This approach allows to store input files in the same folder with full header files.
copy_directory_if_different is added in later version, in 3.26.
We use copy_directory that doesn't detect changes but works faster. At early stages I believe there is no noticeable difference.
Do you know if there is any other reason for other projects to copy headers per file?
Signed-off-by: Tikhomirova, Kseniya <kseniya.tikhomirova@intel.com>
Signed-off-by: Tikhomirova, Kseniya <kseniya.tikhomirova@intel.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Couple of minor nits.
Thanks
Also, it would be great if we could get the precommit CI running ASAP. IIUC the basic configurations would be:
|
Signed-off-by: Tikhomirova, Kseniya <kseniya.tikhomirova@intel.com>
Could you please clarify - is it a blocker for the current PR? Can we add it in the following PRs? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, it would be great if we could get the precommit CI running ASAP. IIUC the basic configurations would be:
- libstdc++/GCC(?)
- MSVC STL/MSVC
- libunwind/libc++abi/libc++/Clang
That should be pretty lean on the CI resources and could probably easily run in the GH-provided runners for now.Could you please clarify - is it a blocker for the current PR? Can we add it in the following PRs?
I don't think it should be a blocker. I'd like it soon though, since it significantly increases confidence that code changes are correct.
Signed-off-by: Tikhomirova, Kseniya <kseniya.tikhomirova@intel.com>
I agree, I will add libsycl build workflow as separate PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @KseniyaTikhomirova! I unresolved one previous comment to follow up some more and added a few other minor comments.
Signed-off-by: Tikhomirova, Kseniya <kseniya.tikhomirova@intel.com>
Hi @KseniyaTikhomirova |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be a fine starting point for now, we can fix things later.
@asudarsa, resolved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for responding to my prior comments. I added a number of new comments, many of which are minor. I would really like to see some of the differences between windows and Linux/UNIX build differences eliminated; particularly the library naming differences and the "d" debug postfix naming. The default build should produce binaries named appropriately for a LLVM/Clang monorepo build and distribution (which shouldn't differ much between Windows and Linux/UNIX).
Signed-off-by: Tikhomirova, Kseniya <kseniya.tikhomirova@intel.com>
Signed-off-by: Tikhomirova, Kseniya <kseniya.tikhomirova@intel.com>
Signed-off-by: Tikhomirova, Kseniya <kseniya.tikhomirova@intel.com>
Signed-off-by: Tikhomirova, Kseniya <kseniya.tikhomirova@intel.com>
Signed-off-by: Tikhomirova, Kseniya <kseniya.tikhomirova@intel.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @KseniyaTikhomirova, this is looking great. I added a few final comments, but will be very happy to approve once we address these.
libsycl/CMakeLists.txt
Outdated
set(LIBSYCL_ABI_NAMESPACE "V${LIBSYCL_MAJOR_VERSION}" CACHE STRING | ||
"The inline ABI namespace used by libsycl. It defaults to Vn where `n` is the current ABI version.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DPC++ uses _V1
for the inline ABI namespace. libc++ defaults to __1
for the inline ABI namespace and specifically requires that the name be a reserved identifier. See
llvm-project/libcxx/CMakeLists.txt
Lines 204 to 207 in 378e9bb
set(LIBCXX_ABI_NAMESPACE "__${LIBCXX_ABI_VERSION}" CACHE STRING "The inline ABI namespace used by libc++. It defaults to __n where `n` is the current ABI version.") | |
if (NOT LIBCXX_ABI_NAMESPACE MATCHES "__.*") | |
message(FATAL_ERROR "LIBCXX_ABI_NAMESPACE must be a reserved identifier, got '${LIBCXX_ABI_NAMESPACE}'.") | |
endif() |
I'm inclined to match libc++ here or to at least use a reserved identifier; one that is distinct from what DPC++ uses so that we have a chance of the Clang and DPC++ implementations being able to coexist.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated in e502190
libsycl/CMakeLists.txt
Outdated
message( FATAL_ERROR | ||
"On Windows libsycl supports compiler which is some version of Microsoft" | ||
" Visual C++ or another compiler simulating the Visual C++ cl" | ||
" command-line syntax" ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
message( FATAL_ERROR | |
"On Windows libsycl supports compiler which is some version of Microsoft" | |
" Visual C++ or another compiler simulating the Visual C++ cl" | |
" command-line syntax" ) | |
message(FATAL_ERROR | |
"When compiling for Windows, libsycl requires a" | |
" version of Microsoft Visual C++ or another compiler" | |
" that uses the Visual C++ cl command-line syntax.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done in e502190
|
||
set(LIB_NAME "sycl") | ||
set(LIB_OUTPUT_NAME "${LIB_NAME}") | ||
if (CMAKE_SYSTEM_NAME STREQUAL Windows) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we always want to link with one of the DLL variants of the MSVC RT library. How about we do what libc++ does and detect attempted use of a non-DLL variant? See
llvm-project/libcxx/CMakeLists.txt
Lines 387 to 390 in 617af3c
if (LIBCXX_ENABLE_SHARED AND CMAKE_MSVC_RUNTIME_LIBRARY AND | |
(NOT CMAKE_MSVC_RUNTIME_LIBRARY MATCHES "DLL$")) | |
message(WARNING "A static CRT linked into a shared libc++ doesn't work correctly.") | |
endif() |
if (CMAKE_SYSTEM_NAME STREQUAL Windows) | |
if (CMAKE_SYSTEM_NAME STREQUAL Windows) | |
if (NOT CMAKE_MSVC_RUNTIME_LIBRARY MATCHES "DLL$") | |
message(FATAL_ERROR "libsycl requires a DLL version of the MSVC CRT.") | |
endif() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check is added in e502190
libsycl/src/CMakeLists.txt
Outdated
set(LIB_NAME "sycl") | ||
set(LIB_OUTPUT_NAME "${LIB_NAME}") | ||
if (CMAKE_SYSTEM_NAME STREQUAL Windows) | ||
if (CMAKE_BUILD_TYPE STREQUAL Debug OR CMAKE_MSVC_RUNTIME_LIBRARY STREQUAL MultiThreadedDebugDLL) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to check for "MultiThreadedDebugDLL" specifically? I think the libc++ logic looks appropriate to use here. See
llvm-project/libcxx/CMakeLists.txt
Lines 677 to 679 in 617af3c
if ((NOT CMAKE_MSVC_RUNTIME_LIBRARY AND uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG") | |
OR (CMAKE_MSVC_RUNTIME_LIBRARY MATCHES "Debug")) | |
set(LIB_SUFFIX "d") |
if (CMAKE_BUILD_TYPE STREQUAL Debug OR CMAKE_MSVC_RUNTIME_LIBRARY STREQUAL MultiThreadedDebugDLL) | |
if ((NOT CMAKE_MSVC_RUNTIME_LIBRARY AND uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG") | |
OR (CMAKE_MSVC_RUNTIME_LIBRARY MATCHES "Debug")) |
I know we expect CMAKE_MSVC_RUNTIME_LIBRARY
to always be set currently, but this logic will still work as expected if we relax that restriction later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't expect it to be always set. We are ok with cmake default value MultiThreaded$<$CONFIG:Debug:Debug>DLL and handle explicitly set values if needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MultiThreadedDebugDLL is the only option that is supported for sycl in Debug mode. Why should we introduce confusion by setting "CMAKE_MSVC_RUNTIME_LIBRARY MATCHES "Debug""?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated this code but left check of full config name "MultiThreadedDebugDLL".
I know that we do a check for "DLL" match a few lines before. Although I want to keep the full name if it is the only option there.
e502190
Signed-off-by: Tikhomirova, Kseniya <kseniya.tikhomirova@intel.com>
This patch introduces libsycl, a SYCL runtime library implementation, as a top-level LLVM runtime project.
SYCL spec: https://registry.khronos.org/SYCL/specs/sycl-2020/html/sycl-2020.html
Commit contains the basic folder layout and CMake infrastructure to build a dummy SYCL library.
This is part of the SYCL support upstreaming effort. The relevant RFCs can be found here:
https://discourse.llvm.org/t/rfc-add-full-support-for-the-sycl-programming-model/74080
https://discourse.llvm.org/t/rfc-sycl-runtime-upstreaming/74479
Upcoming PRs: